const app = getApp()
const util = require('../../../../../../utils/util.js');
const api = require('../../../../../../config/api.js');
Page({
  data: {
    selectType: null,//大类的选择
    contentType: null,//类型的选择
  },
  onLoad: function (options) {
    var _this = this
    var type = options.type
    if (type<4){
      _this.setData({
        selectType: 0,
        contentType: type
      })
    }else{
      _this.setData({
        selectType: 1,
        contentType: type
      }) 
    }
  },
  //选择大类
  selectType: function(e){
    var _this = this
    var index = e.currentTarget.dataset.index;
    _this.setData({
      selectType: index
    })
    if(index==1){
      _this.setData({
        contentType: 4
      })
    }else{
      _this.setData({
        contentType: 1
      })
    }
  },
  //选择小类
  selectContentType: function(e){
    var _this = this
    var index = e.currentTarget.dataset.index;
    _this.setData({
      contentType: index
    })
  },
  //确定
  save: function(){
    var _this = this;
    var type = _this.data.contentType;
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2];
    var prevPageContentType = prevPage.data.ordTheme.contentType;
    if (prevPageContentType != type){
      prevPage.setData({
        ordThemeRecommendList: [],
        dataInfoList: [],
        themeSetting: {},
        themeAmount: {},// 收益明细
        themeAmountDetailsList: [],// 多个收益明细详情
      });
    }
    prevPage.setData({
      ["ordTheme.contentType"]: type
    });
    wx.navigateBack({
      delta: 1
    });
  },
  //取消
  close: function(){
    wx.navigateBack({
      delta: 1
    });
  }
})